#include "headers.h"
//#include <QTreeView>
#include <QDockWidget>

InfoWnd::InfoWnd()
    :QMainWindow()
{
    this->setWindowTitle("Info");
    this->setAttribute(Qt::WA_QuitOnClose, false);
    this->resize(500, 400);

    tabWidget = new QTabWidget(this);

    QWidget* widget=new QWidget();
    QGridLayout* layout=new QGridLayout();
    firstSymbolTXT=new QLineEdit();
    firstSymbolTXT->setReadOnly(true);
    firstSymbolTXT->setFocusPolicy(Qt::NoFocus);
    nonterminalsList=new QListWidget();
    terminalsList=new QListWidget();
    rulesList=new QListWidget();
    actionTableWidget=new QTableWidget();
    gotoTableWidget=new QTableWidget();
    layout->addWidget(new QLabel(QObject::tr("First symbol:")), 0, 0, 1, 2, Qt::AlignRight);
    layout->addWidget(firstSymbolTXT, 0, 2, 1, 4);
    layout->addWidget(new QLabel(QObject::tr("Nonterminals:")), 1, 0, 1, 2);
    layout->addWidget(new QLabel(QObject::tr("Terminals:")), 1, 2, 1, 2);
    layout->addWidget(new QLabel(QObject::tr("Rules:")), 1, 4, 1, 2);
    layout->addWidget(nonterminalsList, 2, 0, 1, 2);
    layout->addWidget(terminalsList, 2, 2, 1, 2);
    layout->addWidget(rulesList, 2, 4, 1, 2);
    QGroupBox* box=new QGroupBox("Parser tables");
    QHBoxLayout* boxLayout=new QHBoxLayout();
    boxLayout->addWidget(actionTableWidget);
    boxLayout->addWidget(gotoTableWidget);
    box->setLayout(boxLayout);
    layout->addWidget(box, 4, 0, 1, 6);
    widget->setLayout(layout);
    tabWidget->addTab(widget, "Grammar");

    lexemesList=new QListWidget();
    tabWidget->addTab(lexemesList, "Lexemes");

    symbolTable=new QListWidget();
    tabWidget->addTab(symbolTable, "Symbol Table");

    derivationTree=new QTreeWidget();
    derivationTree->setStyleSheet(
        "QTreeView::branch:has-siblings:!adjoins-item {"
            "border-image: url(stylesheet-vline.png) 0;}"
        "QTreeView::branch:has-siblings:adjoins-item {"
            "border-image: url(stylesheet-branch-more.png) 0;}"
        "QTreeView::branch:!has-children:!has-siblings:adjoins-item {"
            "border-image: url(stylesheet-branch-end.png) 0;}"
        "QTreeView::branch:has-children:!has-siblings:closed,"
        "QTreeView::branch:closed:has-children:has-siblings {"
            "border-image: none;"
            "image: url(stylesheet-branch-closed.png);}"
        "QTreeView::branch:open:has-children:!has-siblings,"
        "QTreeView::branch:open:has-children:has-siblings  {"
            "border-image: none;"
            "image: url(stylesheet-branch-open.png);}");
    derivationTree->setHeaderLabels(QStringList()<<"Nodes");
    tabWidget->addTab(derivationTree, "Derivation tree");

    QDockWidget* dockWidget=new QDockWidget("Errors List:");
    errorsList=new QListWidget();
    dockWidget->setFeatures(QDockWidget::DockWidgetMovable);
    dockWidget->setWidget(errorsList);

    this->setCentralWidget(tabWidget);
    this->addDockWidget(Qt::BottomDockWidgetArea, dockWidget);
}
